#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;

void sort(int left, int right, vector<int>& w, vector<int>& h);
bool cmp(int wl, int hl, int i, vector<int> w, vector<int> h);




int main()
{
    vector<int> p1, p2;
    int n(0);
    cin >> n;
    for(int i = 0; i < 2*n; i++) 
    {
        int tmp1(0), tmp2(0);
        cin >> tmp1 >> tmp2;
        p1.push_back(tmp1);
        p2.push_back(tmp2);
        // s1.push_back(tmp1);
    }
    int len = p1.size();
    sort(0, len-1, p1, p2);
    // for(int i = 0; i < 2*n; i++) cout << p1[i] << " " << p2[i] << endl;
    long long sum = 0;
    int count1 = 0;
    int count2 = 0;
    for(int i = 0; i < 2*n; i++)  // attention here, 2n people
    {
        if(count1 == n)
        {
            for(int k = i; k < 2*n; k++)
            {
                sum += p2[k];
            }
            break;
        }
        else if(count2 == n)
        {
            for(int k = i; k < 2*n; k++)
            {
                sum += p1[k];
            }
            break;
        }
        if(p1[i] > p2[i])
        {
            sum += p2[i];
            count2++;
        }
        else if(p1[i] < p2[i])
        {
            sum += p1[i];
            count1++;
        }
    }
    cout << sum << endl;
    return 0;
}


void sort(int left, int right, vector<int>& w, vector<int>& h)
{
    if(left >= right) return;

    int i = left;
    int j = right;
    int wl = w[left];
    int hl = h[left];
    while(i < j)
    {
        // cout << i << " " << j << " " << left << endl;
        while(i < j && cmp(wl, hl, j, w, h)) j--;
        w[i] = w[j];
        h[i] = h[j];

        while(i < j && !cmp(wl, hl, i, w, h)) i++;
        w[j] = w[i];
        h[j] = h[i];
    }
    // cout << 1 << endl;
    w[i] = wl;
    h[i] = hl;
    sort(left, i-1, w, h);
    sort(i+1, right, w, h);
}
bool cmp(int wl, int hl, int i, vector<int> w, vector<int> h)
{
    int tmp = abs(w[i]-h[i]);
    int tmp1 = abs(wl-hl);
    if(tmp1 > tmp) return true;
    else return false;
}